#include "qtpropertybrowser.h"
#include "qteditorfactory.h"
#include "qttreepropertybrowser.h"
#include "qtpropertymanager.h"
#include "qtvariantproperty.h"
#include "qttreepropertybrowser.h"
class QDoubleSpinBox;

class DecoratedDoublePropertyManager : public QtDoublePropertyManager
{
	Q_OBJECT
public:
	DecoratedDoublePropertyManager(QObject *parent = 0);
	~DecoratedDoublePropertyManager();

	QString prefix(const QtProperty *property) const;
	QString suffix(const QtProperty *property) const;
	public Q_SLOTS:
		void setPrefix(QtProperty *property, const QString &prefix);
		void setSuffix(QtProperty *property, const QString &suffix);
Q_SIGNALS:
		void prefixChanged(QtProperty *property, const QString &prefix);
		void suffixChanged(QtProperty *property, const QString &suffix);
protected:
	QString valueText(const QtProperty *property) const;
	virtual void initializeProperty(QtProperty *property);
	virtual void uninitializeProperty(QtProperty *property);
private:
	struct Data {
		QString prefix;
		QString suffix;
	};
	QMap<const QtProperty *, Data> propertyToData;
};


class DecoratedDoubleSpinBoxFactory : public QtAbstractEditorFactory<DecoratedDoublePropertyManager>
{
	Q_OBJECT
public:
	DecoratedDoubleSpinBoxFactory(QObject *parent = 0);
	~DecoratedDoubleSpinBoxFactory();
protected:
	void connectPropertyManager(DecoratedDoublePropertyManager *manager);
	QWidget *createEditor(DecoratedDoublePropertyManager *manager, QtProperty *property,
		QWidget *parent);
	void disconnectPropertyManager(DecoratedDoublePropertyManager *manager);
	private slots:

		void slotPrefixChanged(QtProperty *property, const QString &prefix);
		void slotSuffixChanged(QtProperty *property, const QString &prefix);
		void slotEditorDestroyed(QObject *object);
private:
	/* We delegate responsibilities for QtDoublePropertyManager, which is a base class
	of DecoratedDoublePropertyManager to appropriate QtDoubleSpinBoxFactory */
	QtDoubleSpinBoxFactory *originalFactory;
	QMap<QtProperty *, QList<QDoubleSpinBox *> > createdEditors;
	QMap<QDoubleSpinBox *, QtProperty *> editorToProperty;
};